package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.AssociateDto;
import com.heima.search.pojos.ApAssociateWords;
import com.heima.search.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/v1/associate")
@RestController
public class AssociateConrtoller {

    @Autowired
    private HistoryService historyService;

    /**
     * 联想词搜索
     * @param dto
     * @return
     */
    @PostMapping("/search")
    public ResponseResult search(@RequestBody AssociateDto dto){
        List<ApAssociateWords> list = historyService.search(dto);
        return ResponseResult.okResult(list);
    }
}
